import { NavBar, Input, Form } from 'antd-mobile';

import './style.scss';

export default function(props) {
  const { onOk, onClose } = props;
  const [form] = Form.useForm();

  const handleSend = () => {
    form.validateFields().then(value => {
      onOk(value);
    });
  }

  return (<div className="sendLinkPage">
    <NavBar
      onBack={onClose} style={{ background: '#fff', border: 'none' }}
      right={<a onClick={handleSend}>发送</a>}>链接</NavBar>
    <Form form={form} style={{ margin: '16px 0' }}>
      <Form.Item name='href' label='链接地址' rules={[{ required: true }]}>
        <Input placeholder='请输入链接地址' />
      </Form.Item>
      <Form.Item name='title' label='链接标题' rules={[{ required: true }]}>
        <Input placeholder='请输入链接标题' />
      </Form.Item>
    </Form>
  </div>)
}